package dowork;

import android.widget.EditText;
import android.widget.RelativeLayout;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.sutuijingling.a.f;
import com.sutuijingling.utils.c;

public class TestRunner extends UiAutomatorTestCase {
    static String TAG = "TMRunnder";

    private void testInitInputMethod() {
        try {
            new f(getUiDevice()).b();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void testPasswordInput() throws UiObjectNotFoundException {
        new UiObject(new UiSelector().className(RelativeLayout.class).resourceId("com.taobao.taobao:id/userPasswordInput")).getChild(new UiSelector().className(EditText.class)).setText("234525235");
        c.e();
    }

    private void testScrollUpAndDown() {
        UiDevice uiDevice = getUiDevice();
        int displayWidth = uiDevice.getDisplayWidth();
        int displayHeight = uiDevice.getDisplayHeight();
        displayWidth = (displayWidth * 2) / 4;
        uiDevice.swipe(displayWidth, (displayHeight * 3) / 4, displayWidth, (displayHeight * 2) / 4, 10);
    }

    public void testDemo() throws UiObjectNotFoundException {
        UiDevice uiDevice = getUiDevice();
        System.out.println("with:" + uiDevice.getDisplayWidth());
        System.out.println("pacages:" + uiDevice.getCurrentPackageName());
        try {
            System.out.println(" <<<Start to Work>>>");
            testScrollUpAndDown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
